home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 773 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.6 KB  |  161 lines

  1. Path: sn.no!usenet
  2. From: elvemo@sn.no (Rune Elvemo)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Problems with BOOPSI prop gadget
  5. Date: 10 Jan 1996 19:54:02 GMT
  6. Organization: SN Internett
  7. Message-ID: <3395.6583T1242T1959@sn.no>
  8. NNTP-Posting-Host: sinsen.sn.no
  9. X-Newsreader: THOR 2.1 (Amiga;TCP/IP beta 5) *UNREGISTERED*
  10.  
  11. I have a problem when using BOOPSI gadgets.... As far as I am concerned, this
  12. program should work, but when I compile it, and start it, I can't see the
  13. gadget..........
  14.  
  15. What this program is SUPPOSED to do, is to open a window with a prop gadget,
  16. and the prop gadget will send messages to the program when it changes....
  17.  
  18.  
  19. /* ------------------------------------------- */
  20. #include <exec/types.h>
  21. #include <utility/tagitem.h>
  22. #include <intuition/intuition.h>
  23. #include <intuition/screens.h>
  24. #include <intuition/gadgetclass.h>
  25. #include <intuition/icclass.h>
  26.  
  27. #include <clib/exec_protos.h>
  28. #include <clib/intuition_protos.h>
  29.  
  30. struct Library *IntuitionBase;
  31.  
  32. struct Window *win;
  33. struct IntuiMessage *msg;
  34. struct Gadget *prop;
  35.  
  36. /* prototype */
  37. BOOL MakeProp(void);
  38.  
  39. #define PROPGADID 1L
  40.  
  41. main()
  42. {
  43. struct Screen *pub;
  44. BOOL NotEnough = FALSE; /* enough mem for prop gadget? */
  45.  
  46. if (IntuitionBase = OpenLibrary("intuition.library", 37))
  47.      {
  48.      if (pub = LockPubScreen("Workbench"))
  49.           {
  50.           if (win = OpenWindowTags(NULL,
  51.                                    WA_Left, 0, WA_Top, 0,
  52.                                    WA_Width, pub->Width,
  53.                                    WA_Height, pub->Height,
  54.                                    WA_Flags, WFLG_CLOSEGADGET |
  55. WFLG_DEPTHGADGET,
  56.                                    WA_PubScreen, pub,
  57.                                    WA_Title, "/mi Rulez!",
  58.                                    WA_IDCMP, IDCMP_CLOSEWINDOW |
  59. IDCMP_IDCMPUPDATE,
  60.                                    TAG_END))
  61.                {
  62.                NotEnough = MakeProp();
  63.  
  64.                if (!NotEnough)
  65.                     HandleIDCMP();
  66.  
  67.  
  68.                CloseWindow(win);
  69.                }
  70.           else
  71.                printf("Not enough mem for window! sorry!\n");
  72.  
  73.           UnlockPubScreen(NULL, pub);
  74.           }
  75.      else
  76.           printf("Not enough mem for screen, sorry!\n");
  77.  
  78.      CloseLibrary(IntuitionBase);
  79.      }
  80. else
  81.      printf("not enough memory for IntuitionBase\n");
  82.  
  83. printf("program quitin'");
  84. }
  85.  
  86.  
  87. /* make the propgadget */
  88. BOOL MakeProp(void)
  89. {
  90. BOOL notenough;
  91.  
  92. if (prop = NewObject(NULL, "propgclass",
  93.      GA_ID, PROPGADID,
  94.      GA_Top, 18,
  95.      GA_Left, 10,
  96.      GA_Width, 10,
  97.      GA_Height, 100,
  98.  
  99.      PGA_Total, 50,
  100.      PGA_Top, 1,
  101.      PGA_Visible, 10,
  102.  
  103.      PGA_NewLook, TRUE,
  104.  
  105. /* set the window of the program to the target */
  106.      ICA_TARGET, ICTARGET_IDCMP,
  107.  
  108.      TAG_END))
  109.      {
  110.      notenough = FALSE;
  111.      printf("Gadget'en er σpnet!");
  112.      }
  113. else
  114.      {
  115.      notenough = TRUE;
  116.      }
  117. return(notenough);
  118. }
  119.  
  120. /* Check if there are some IDCMP event at our port */
  121. HandleIDCMP()
  122. {
  123. BOOL done = FALSE;
  124. ULONG Class;
  125. APTR IAddress;
  126. struct TagItem *test;
  127.  
  128. while (!done)
  129.      {
  130.      WaitPort(win->UserPort);
  131.  
  132.      while (msg = GetMsg(win->UserPort))
  133.           {
  134.           Class = msg->Class;
  135.           IAddress = msg->IAddress;
  136.  
  137.           ReplyMsg(msg);
  138.  
  139.           switch (Class)
  140.                {
  141.                case IDCMP_CLOSEWINDOW:
  142.                     done = TRUE;
  143.                     break;
  144.                case IDCMP_IDCMPUPDATE:
  145.                     test = IAddress;
  146.  
  147.                     printf("The Prop is now at: %d\n", IAddress);
  148.                     break;
  149.                }
  150.           }
  151.      }
  152. }
  153. /* --------------------------------------------- */
  154.  
  155. Anyone who knows what is wrong with this?
  156.  
  157. Rune Elvemo
  158. elvemo@sn.no
  159. -It's cool to be clear :-)
  160.  
  161.